package com.fiveGroup.controller;

import com.fiveGroup.pojo.vo.DataVo;
import com.fiveGroup.service.OrderService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

//数据分析管理层
@RestController
@RequestMapping("/api/analytics")
@Slf4j
@RequiredArgsConstructor
public class BackgroundAnalyticsController {


    private final OrderService orderService;

    @GetMapping("/dailyOrderCount")
    public DataVo dailyOrderCount(@RequestParam int days) {
        log.info("Received request to get daily order count for last {} days", days);
        return DataVo.success(orderService.countOrdersByDay(days));
    }
}
